package com.zircloud.tenant.web;


import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zircloud.tenant.dto.UserInfoDto;
import com.zircloud.tenant.service.UserInfoService;

/**
 * 用户管理
 * @author test
 *
 */
@RestController
@RequestMapping("/v1/users")
public class UserInfoController {

	
	@Resource
	private UserInfoService userInfoService;
	
	/**
	 * 根据ID查询用户
	 * @param id
	 * @return
	 */
	@GetMapping("/details/{id}")
	public UserInfoDto getUserbyId(@PathVariable("id") Integer id) {
		return userInfoService.getUserByid(id);
	}
	
	/**
	 * 根据ID查询用户
	 * @param id
	 * @return
	 */
	@GetMapping("/query/{name}")
	public UserInfoDto getUserbyname(@PathVariable("name") String name) {
		return userInfoService.getUserByname(name);
	}
	
	/**
	 * 创建用户
	 * @param dto
	 * @return
	 */
	@PostMapping("/create")
	public boolean create(@RequestBody UserInfoDto dto) {
		return userInfoService.creaate(dto);
	}
}
